package com.achievo.know.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import com.dayatang.domain.BaseEntity;
import com.dayatang.domain.InstanceFactory;

@Entity
@Table(name="RAMS_USER_FAVORITE")
public class UserFavorite extends BaseEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = 9135874798163844843L;

	//加入时间
	@NotNull
	@Column(name="ADD_TIME",nullable=false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date addTime;
	
	@NotNull
	@Column(name="FILE_ID",nullable=false)
	private Long fileId;
	
	@NotNull
	@Column(name="USER_ID",nullable=false)
	private Long userId;

	public Date getAddTime() {
		return addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	public Long getFileId() {
		return fileId;
	}

	public void setFileId(Long fileId) {
		this.fileId = fileId;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	@Override
	public boolean equals(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return 0;
	}
	
	/**
	 * lingen.liu 仓储
	 */
	private static UserFavoriteRepository userFavoriteRepository;

	public static UserFavoriteRepository getUserFavoriteRepository() {
		if (userFavoriteRepository == null) {
			userFavoriteRepository = InstanceFactory
					.getInstance(UserFavoriteRepository.class);
		}
		return userFavoriteRepository;
	}

	public static void setUserRepositoryRepository(
			UserFavoriteRepository userFavoriteRepository) {
		UserFavorite.userFavoriteRepository = userFavoriteRepository;
	}
	
	public  void add(){
		this.setAddTime(new Date());
		getUserFavoriteRepository().save(this);
	}
	
}
